<template>
    <v-dialog
        v-model="dialog"
        persistent
        max-width="600px"
    >
      <template v-slot:activator="{ on, attrs }">
        <v-btn
            style="position: absolute;bottom: 10%; left: 3%;color: white;font-size: 32px;border-radius: 30px" color="#FD564F" x-large
            v-bind="attrs"
            v-on="on"
        >
          <v-icon>mdi-lead-pencil</v-icon>
          发帖
        </v-btn>
      </template>
      <v-card>
        <v-card-title>
          <span class="text-h5">发帖</span>
        </v-card-title>
        <v-card-text>
          <v-container>
            <v-row>
              <v-col
                  cols="12"
              >
                <v-text-field
                    label="标题"
                    required
                    v-model="title"
                ></v-text-field>
              </v-col>
            </v-row>
            <v-row>
              <v-col
                  cols="12"
              >
                <v-textarea label="正文" required v-model="content">
                </v-textarea>
              </v-col>
            </v-row>
          </v-container>
        </v-card-text>
        <v-card-actions>
          <v-spacer></v-spacer>
          <v-btn
              color="#FD564F"
              text
              @click="dialog = false"
              large
              style="font-size: 20px"
          >
            取消
          </v-btn>
          <v-btn
              color="green"
              text
              @click="releasepost"
              large
              style="font-size: 20px"
          >
            发布
          </v-btn>
        </v-card-actions>
      </v-card>
    </v-dialog>
</template>

<script>

export default {
  name: "PostDialog",
  components: {},
  data: () => ({
    title: "",
    content: "",
    dialog: false,
  }),
  methods:{
    releasepost(){
      this.$api.article.releasepost(this.title,this.content,this.$store.getters.getUserId).then(res=>{
        if (res.success){
          this.$Message.success("发布成功")
          this.$router.go(0)
        }
        else {
          this.$Message.error("发布失败")
        }
      })
    }
  }
}
</script>

<style scoped>

</style>